package com.margo.project.web.client.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.margo.project.web.client.model.MargoGirlVO;

/**
 * margo-spring-web项目发送请求
 * 测试RestTemplate
 * @author fxb208
 *
 */
@RestController
@RequestMapping("/rest")
public class MargoRestTemplateController {
	
	Logger logger=LoggerFactory.getLogger(this.getClass());
	/**
	 * content-type=application/x-www-form-urlencoded
	 * @param name
	 * @param age
	 * @return
	 */
	@RequestMapping("form")
	public String form(String name,int age) {
		logger.info("name:"+name+"|age:"+age);
		return "hello word";
	}
	
	/**
	 * content-type=application/json
	 * @param margoGirlVO
	 * @return
	 */
	@RequestMapping("/json")
	public String json(@RequestBody MargoGirlVO margoGirlVO) {
		logger.info(margoGirlVO.toString());
		return "hello word";
	}
	
	/**
	 * content-type= multipart/form-data
	 * @param file
	 * @param name
	 * @return
	 */
	@RequestMapping("/file")
	public String json(MultipartFile file,String name) {
		logger.info("file:"+file.getName()+"|name:"+name);
		return "hello word";
	}
}
